#pragma once

#include <fstream>

class DIRenderer;
class DIResourceManager;
class DLayer;
class DGame;
class DIActor;

typedef std::vector<boost::shared_ptr<DLayer> > ListLayers;

class DWorld : public boost::enable_shared_from_this<DWorld>
{
public:
    DWorld(boost::shared_ptr<DGame> game);
	~DWorld(void);

	void update(float dt);
	void render(boost::shared_ptr<DIRenderer> renderer);
    bool load(const std::string& strPath);

    // main layer is indexed by 0
    void addActor(boost::shared_ptr<DIActor> newActor, int nLayer = 0);
private:
    bool loadMap(const std::string& strPath);
    bool loadLayer(boost::shared_ptr<DLayer> layer, std::ifstream& in);

    boost::weak_ptr<DGame> m_game;
    boost::shared_ptr<DIResourceManager> m_resourceManager;
    ListLayers m_layers;
};
